﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr">

<head>
	<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
	<title>L'espace adhérent</title>
	<link rel="stylesheet" href="../css/style.css" type="text/css" />
	<script type="text/javascript" src="../js/jquery-1.9.1.js" charset="utf8"></script>
	<script type="text/javascript" src="../js/validation_inscription.js" charset="utf8"></script>
	
</head>

<body>
	<div id="conteneur">
		
		<?php include "menu.php"; ?>
	
		<div id="contenu">
			<p id="ariane">Vous êtes ici : <a id ="accueil" href="../index.html" title="revenir à l'accueil">accueil</a> > espace adhérent</p>
			<?php include "right_menu.php";?>
			
			<h1 id="un">Validation des inscriptions</h1>
			<section class="main" id="tableDeValidation">
			<?php
				
				error_reporting(E_ALL);
				ini_set("display_errors", 1);
				
				// Connexion à la base de données.
				include "../dyn/connexion.php"; 
				
				if (isset($_GET["q"])){
					$q = $_GET["q"];
					$mail = $_GET["mail"];
					
					 if(preg_match('`supprimer`', $q)){
						mysql_query("DELETE FROM Utilisateur WHERE email = '$mail';");
					}
					if(preg_match('`valider`', $q)){
						mysql_query("UPDATE Utilisateur set statut = 1 WHERE email = '$mail';");
					}
				}
				
				// Creation et envoi de la requete de récupération des consultants.
				$tableau = mysql_query("SELECT * FROM Utilisateur WHERE statut = 0;");
				
				if(mysql_num_rows($tableau) > 0){
					$rang = 0;
					echo '<table>';
	
						echo '<tr>';
							echo '<th>Nom</th>';
							echo '<th><b>Prénom</th>';
							echo '<th><b>Adresse</th>';
							echo '<th><b>Mail</th>';
							echo '<th></th>';
							echo '<th></th>';
						echo '</tr>';
						
					while($row = mysql_fetch_array($tableau))
					{
						echo '<tr>';
							echo '<td>'.$row["nom"].'</td>';
							echo '<td>'.$row["prenom"].'</td>';
							echo '<td>'.$row["adresse"].'</td>';
							echo '<td>'.$row["email"].'</td>';
							echo '<td><button id="valider'.$rang.'" type="submit">Confirmer</button></td>';
							echo '<td><button id="supprimer'.$rang.'" type="submit">Refuser</button></td>';
						echo '</tr>'."\n";
						$rang = $rang + 1;
					}
					echo '</table>'."\n";
					echo '<br>';
				}else{
					echo "<p>Pas de nouvelles demandes</p>";
				}

			
				// On libère le résultat de la requete.
				mysql_free_result($tableau);
				
			?>
			</section>
		</div>
	</div>
	
	<?php include "foot.php";?>
</body>

</html>